home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / asm3.zip / READWRIT.ASM < prev    next >
Assembly Source File  |  1986-06-05  |  5KB  |  124 lines

  1. title    READWRIT.COM -- VERSION 1.0
  2. ;
  3. ;       ***************************************************
  4. ;       A utility that changes the mode of a file to read-
  5. ;       write status so that it can be changed or erased
  6. ;       by ordinary means.
  7. ;       ***************************************************
  8. ;
  9. code segment
  10. ;
  11. org     100h                    ; this is a COM file
  12. ;
  13. assume  cs:code,ds:code,es:code
  14. ;
  15. BEGIN:
  16.         jmp     main            ;avoid the data area
  17. ;
  18. ;       ===================================================
  19. ;
  20. ;       Data area:
  21. ;
  22. copyright       db      'Version 1.0 -- Copyright 1985 by Winn L. Rosch, Esq.'
  23.                                 ; credit where credit is due
  24. nothing         db      1ah     ; this byte lets us type the COM file
  25.                                 ;     without disasters
  26. ;
  27. ;       Error messages:
  28. ;
  29. error1          db      'Error.  Bad file specifications.$'
  30. error2          db      'Error.  No such file.$'
  31. error3          db      'Error.  Path not found.$'
  32. error5          db      'Error.  Access denied.$'
  33. message         db      'Function completed as specified.$'
  34. ;
  35. ;       ===================================================
  36. ;
  37. main:
  38.         push    cs              ; make sure that data segment is same
  39.         pop     ds              ;     as code segment
  40.         mov     bx,0081h        ; check to be sure a filename is given
  41.         mov     dl,[bx]         ; move byte following filename into DL
  42.         cmp     dl,0dh          ; check for carriage return
  43.         jz      er1             ; if we find a carriage return, run error message
  44.         mov     dx,0082h        ; ds-dx now points to filename, as required
  45.                                 ;     by the DOS function we'll be calling
  46.         mov     bx,dx
  47. ;
  48. ;       ---------------------------------------------------
  49. ;       This routine loops through the characters on the
  50. ;       command line, looking for a carriage return, which
  51. ;       delimits the filename
  52. ;       ---------------------------------------------------
  53. ;
  54. marker:
  55.         mov     al,[bx]         ; move character position into AL
  56.         cmp     al,0dh          ; check for carriage return
  57.         jz      carriage_return ; carriage return indicates end of filename
  58.         inc     bx              ; advance to next character
  59.         jmp     marker          ; keep going until we find a carriage return
  60. ;
  61. ;       ---------------------------------------------------
  62. ;       This routine merely changes the carriage return on
  63. ;       the command line into the zero required by the
  64. ;       function call so that it recognizes the proper
  65. ;       filename
  66. ;       ---------------------------------------------------
  67. ;
  68. carriage_return:
  69.         xor     ah,ah           ; make a zero
  70.         mov     [bx],ah         ; changes the space after the filename
  71.                                 ;      into a zero required by function
  72.         mov     ah,43h          ;
  73.         mov     al,00h          ; tells DOS to read attribute byte
  74.         int     21h             ; make function call
  75.         call    error_check     ; check for errors
  76.         mov     ah,43h          ; DOS file attribute byte function call
  77.         mov     al,01h          ; indicates that attribute byte to be changed
  78.         and     cx,0fffeh       ; set attribute to readwrite
  79.         int     21h             ; make function call
  80.                                 ; if everything went okay, say so
  81.         mov     dx,offset message
  82. ;
  83. sign_off:
  84.         mov     ah,09           ; load DOS print string function
  85.         int     21h             ; call DOS
  86.         int     20h             ; exit
  87. ;
  88. ;
  89. ;
  90. er1:
  91.         mov     dx,offset error1
  92.         jmp     sign_off
  93. er2:
  94.         mov     dx,offset error2
  95.         jmp     sign_off
  96. er3:
  97.         mov     dx,offset error3
  98.         jmp     sign_off
  99. er5:
  100.         mov     dx,offset error5
  101.         jmp     sign_off
  102. ;
  103. ;       ---------------------------------------------------
  104. ;       The following procedure checks the character returned
  105. ;       in the AX register for errors after making the function
  106. ;       call.  If an error is found, it loads the appropriate
  107. ;       message, then exits.
  108. ;       ---------------------------------------------------
  109. ;
  110. error_check     proc    near
  111. ;
  112.         cmp     ax,2
  113.         jz      er2
  114.         cmp     ax,3
  115.         jz      er3
  116.         cmp     ax,5
  117.         jz      er5
  118.         ret
  119. ;
  120. error_check     endp
  121. ;
  122. code            ends
  123.                 end BEGIN
  124.